home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.02 Feb 93 / Screen I⁄O Classes / B Classes / B.c / BBitMapDoc.c next >
Encoding:
C/C++ Source or Header  |  1992-07-12  |  2.5 KB  |  101 lines  |  [TEXT/KAHL]

  1. /***********************************************************
  2.  * BBitMapDoc.c
  3.  *
  4.  * SUPERCLASS = BDisplayOutput
  5.  *
  6.  * Class for rapid dumping of a bitmap to a window.
  7.  *
  8.  * © copyright 1992, KSS Scientific Consultants
  9.  *
  10.  ***********************************************************/
  11.  
  12. #include <CDecorator.h>
  13. #include <CDesktop.h>
  14. #include <CScrollPane.h>
  15. #include <CWindow.h>
  16. #include <constants.h>
  17. #include "BBitMapDoc.h"
  18. #include "BBitMapPane.h"
  19.  
  20. #define    WINDculture        500        // Resource ID for WIND template
  21. #define        BITMAPWIDTH        640
  22. #define        BITMAPHEIGHT    480
  23.  
  24. extern CDecorator    *gDecorator;
  25. extern CDesktop        *gDesktop;
  26.  
  27. /************************************************************
  28.  * IBBitMapDoc()
  29.  *
  30.  * Initialization method
  31.  *
  32.  ************************************************************/
  33.  
  34. void BBitMapDoc::IBBitMapDoc(CApplication *aSupervisor, Boolean printable)
  35. {
  36.     inherited::IBDisplayOutput(aSupervisor, printable);
  37. }
  38.  
  39. /******************************************************************
  40.  * BuildWindow
  41.  *
  42.  * Override BuildWindow so a floating window is created and it is 
  43.  *   not positioned by the Decorator.
  44.  *
  45.  *******************************************************************/
  46.  
  47. void BBitMapDoc::BuildWindow (Handle theData)
  48.  
  49. {
  50.     CScrollPane        *theScrollPane;
  51.     BBitMapPane        *theMainPane;
  52.     Rect            bounds, tRect;
  53.     LongRect        bitMapRect;
  54.  
  55.     itsWindow = new(CWindow);
  56.     itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);
  57.     itsWindow->Move(40, 60);
  58.     itsWindow->ChangeSize(screenBits.bounds.right, screenBits.bounds.bottom - 38);
  59.     tRect = screenBits.bounds;
  60.     SetRect(&bounds, 0, 0, tRect.right, tRect.bottom - 38);
  61.     SetLongRect(&bitMapRect, 0, 0, BITMAPWIDTH, BITMAPHEIGHT);
  62.     
  63.     theScrollPane = new(CScrollPane);
  64.     
  65.     theScrollPane->IScrollPane(itsWindow, this, 10, 10, 0, 0,
  66.                                 sizELASTIC, sizELASTIC,
  67.                                 TRUE, TRUE, TRUE);
  68.  
  69.     theScrollPane->FitToEnclFrame(TRUE, TRUE);
  70.  
  71.     theMainPane = new(BBitMapPane);
  72.     itsMainPane = theMainPane;
  73.     itsGopher = theMainPane;
  74.  
  75.     theMainPane->IBBitMapPane(theScrollPane, this, bounds.right - SBARSIZE, 
  76.                                 bounds.bottom - SBARSIZE, 0, 0, sizELASTIC, sizELASTIC, 
  77.                                 &bitMapRect, 0L, TRUE);
  78.  
  79.     theScrollPane->InstallPanorama(theMainPane);
  80.  
  81.     gDecorator->PlaceNewWindow(itsWindow);
  82. }
  83.  
  84. /************************************************************
  85.  * OutputMap()
  86.  *
  87.  * Initialize bitmap window and output bitmap.
  88.  *
  89.  ***********************************************************/
  90.  
  91. void BBitMapDoc::OutputMap(BitMap *theBitMap)
  92. {
  93.     BuildWindow(0L);
  94.     itsWindow->Select();
  95.     
  96.     ((BBitMapPane*)itsMainPane)->InstallBitMap(theBitMap);
  97.  
  98.     EventManagement();
  99.     
  100. }
  101.